GLOBAL
	current_frame = 1;
	NEXT_FRAME_DELAY = 5;
	string current_state;
	int frame_counter;
	_interval state_frames;
END

FUNCTION int getFlags(_vector3D direction)
BEGIN
	IF ( direction.varX == 1 )
		return 0;
	ELSEIF ( direction.varX == -1 )
		return 1;
	END
	return 1000;
END

PROCESS int updateAnimation(string state, _interval animInterval, int doLoop)
	BEGIN
	IF ( current_state != state )
		//print("cambio a animacion " + currentState);
		state_frames = animInterval;
		frame_counter = 1;
		current_frame = current_state_frames.init;
		current_state = state;
		return current_frame;
	END
	
	IF ( frame_counter <= NEXT_FRAME_DELAY)
		frame_counter++;
		//print("frame_counter ++");
	ELSE
		frame_counter = 1;
		IF ( current_frame < current_state_frames.final )
			current_frame = current_frame +1;
		ELSE
			IF (doLoop == -1)
				current_frame = current_state_frames.init;
			ELSEIF(doLoop > 0)
				current_frame = current_state_frames.init;
				doLoop--;
			ELSE
				//IF(nextState != "")
					//currentState = nextState;
					//current_state_frames = next_state_frames;
				//ELSE
					current_frame = current_state_frames.final ;
					//nextState = "";
				//END
			END
		END
		return current_frame;
		
	END
	return current_frame;			
END 